package com.qfedu.tantu.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateTimeFormatUtil {
    private String str = "yyyy-MM-dd HH:mm:ss";
        public String DateFormat(Date date){
            SimpleDateFormat sdf = new SimpleDateFormat(str);
            String df = sdf.format(date);
            return df;
        }

        public String CurDateFormt(){
            Date date = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat(str);
            String df = sdf.format(date);
            return df;
        }
        public static void main(String[] args){
            // 转换格式
            Date date = new Date();
            DateTimeFormatUtil dateUtil = new DateTimeFormatUtil();
            String dateStr = dateUtil.DateFormat(date);
            System.out.println(dateStr);

            // 获取当前时间
            String curDateStr = dateUtil.CurDateFormt();
            System.out.println(curDateStr);
        }


}
